package ru.vpitervip.app.client.activity;

import java.util.List;

import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceController;
import com.google.web.bindery.requestfactory.shared.Receiver;


import ru.vpitervip.app.client.place.FlatsPlace;
import ru.vpitervip.app.client.request.AppRequestFactory;
import ru.vpitervip.app.client.ui.SearchPanel;
import ru.vpitervip.client.managed.request.FacilityProxy;
import ru.vpitervip.client.managed.request.MetroStationProxy;

public class SearchHandler implements SearchPanel.Presenter{
	
	
	
	private AppRequestFactory requestFactory;
	private PlaceController placeController;
    private SearchPanel view;



	public SearchHandler(SearchPanel panel,AppRequestFactory requestFactory,PlaceController placeController) {
		this.requestFactory=requestFactory;
		this.placeController=placeController;
		this.view=panel;
		init();
	}
	
	
	@SuppressWarnings("deprecation")
	private void init(){
		
		
		view.setPresenter(this);
		
		Receiver<List<MetroStationProxy>> receiver=new Receiver<List<MetroStationProxy>>() {
			@Override
			public void onSuccess(List<MetroStationProxy> metroStations) {
//				System.out.println(metroStations.size());
				view.setMetroStations(metroStations);
				
				
			}
		};
		requestFactory.appMetroStationRequest().findVipMetroStations().fire(receiver);
		
		
	}
	
	
	
	
	@Override
	public void goTo(FlatsPlace place) {
		placeController.goTo(place);
		
	}
	
	

}
